var TBM = TBM || {};
TBM.arktop = new
function() {
    function c(h) {
        var g = document.cookie.match("(?:^|;)\\s*" + h + "=([^;]*)");
        return (g && g[1]) ? decodeURIComponent(g[1]) : ""
    }
    var d = c("tracknick");
    var f = c("sn");
    var b = c("_nk_");
    var a = c("cart_items") || 0;
    var e = "ark:itemCount";
    this.writeLoginStatus = function(g, m, k) {
        var l = m + "/member/login.jhtml";
        var j = m + "/member/register.jhtml?f=b2c&redirect_url=http://mall.taobao.com";
        var i = g + "/logout.htm";
        if (k && k != "") {
            l += "?redirectURL=" + k
        }
        var h = "";
        if (f != "") {
            h += '<li class="member">\u60a8\u597d\uff0c' + unescape(escape(f)) + '\uff01<a href="' + i + '">[\u9000\u51fa]</a></li>\n'
        } else {
            if (b != "") {
                h += '<li class="member">\u60a8\u597d\uff0c' + unescape(b.replace(/\\u/g, "%u")) + '\uff01<a href="' + i + '">[\u9000\u51fa]</a></li>\n'
            } else {
                if (d == "") {
                    h += '<li class="member">\u60a8\u597d\uff0c\u6b22\u8fce\u6765\u6dd8\u5b9d\u5546\u57ce\uff01<a href="' + l + '">[\u8bf7\u767b\u5f55]</a>&nbsp;&nbsp;<a href="' + j + '">[\u514d\u8d39\u6ce8\u518c]</a></li>\n'
                } else {
                    h += '<li class="member">\u60a8\u597d\uff0c' + unescape(d.replace(/\\u/g, "%u")) + '\uff01<a href="' + l + '">[\u8bf7\u767b\u5f55]</a>&nbsp;&nbsp;<a href="' + j + '">[\u514d\u8d39\u6ce8\u518c]</a></li>\n'
                }
            }
        }
        document.write(h)
    };
    this.writeCartStatus = function(i) {
        var n = "http://trade.taobao.com/trade/itemlist/list_sold_items.htm";
        var g = "http://favorite.taobao.com/collectList.htm";
        var p = "http://trade.taobao.com/trade/itemlist/list_bought_items.htm";
        var j = i + "/shop/view_shop.htm";
        var l = "http://ishop.taobao.com/shopManageIndex.htm";
        var o = "http://trade.taobao.com/trade/point/point_detail.htm";
        var k = "http://buy.taobao.com/auction/cart/my_cart.htm";
        var h = "";
        if (f != "") {
            h += '<li class="my-shop"><a href="' + n + '">\u8ba2\u5355\u7ba1\u7406</a></li>\n';
            h += '<li class="my-order"><a href="' + l + '">\u5e97\u94fa\u7ba1\u7406</a></li>\n'
        } else {
            var m = document.getElementById("tabName");
            if (b != "") {
                if (m && m.value == "tab12") {
                    p = "http://jipiao.taobao.com/order_manager.htm?";
                    h += '<li class="my-shopping-cart"><a id="ark:listCart" href="' + k + '" ><span>\u8d2d\u7269\u8f66</span></a></li>\n';
                    h += '<li class="my-favorate"><a href="' + g + '">\u6536\u85cf\u5939</a></li>\n';
                    h += '<li class="my-order"><a href="' + p + '">\u673a\u7968\u8ba2\u5355</a></li>\n';
                    h += '<li class="my-point"><a href="' + o + '">\u79ef\u5206</a></li>\n'
                } else {
                    h += '<li class="my-shopping-cart"><a id="ark:listCart" href="' + k + '" ><span>\u8d2d\u7269\u8f66</span></a></li>\n';
                    h += '<li class="my-favorate"><a href="' + g + '">\u6536\u85cf\u5939</a></li>\n';
                    h += '<li class="my-order"><a href="' + p + '" id="ark:myOrder"><span>\u6211\u7684\u8ba2\u5355</span></a></a></li>\n';
                    h += '<li class="my-point"><a href="' + o + '">\u79ef\u5206</a></li>\n'
                }
            } else {
                if (m && m.value == "tab12") {
                    p = "http://jipiao.taobao.com/order_manager.htm?";
                    h += '<li class="my-shopping-cart"><a id="ark:listCart" href="' + k + '" ><span>\u8d2d\u7269\u8f66</span></a></li>\n';
                    h += '<li class="my-favorate"><a href="' + g + '">\u6536\u85cf\u5939</a></li>\n';
                    h += '<li class="my-order"><a href="' + p + '">\u673a\u7968\u8ba2\u5355</a></li>\n';
                    h += '<li class="my-point"><a href="' + o + '">\u79ef\u5206</a></li>\n'
                } else {
                    h += '<li class="my-shopping-cart"><a id="ark:listCart" href="' + k + '" ><span>\u8d2d\u7269\u8f66</span></a></li>\n';
                    h += '<li class="my-favorate"><a href="' + g + '">\u6536\u85cf\u5939</a></li>\n';
                    h += '<li class="my-order"><a href="' + p + '" id="ark:myOrder"><span>\u6211\u7684\u8ba2\u5355</span></a></a></li>\n';
                    h += '<li class="my-point"><a href="' + o + '">\u79ef\u5206</a></li>\n'
                }
            }
        }
        document.write(h)
    };
    this.reGetCartItemsFromShop = function(g) {}
};
if (!Array.prototype.forEach) {
    Array.prototype.forEach = function(b) {
        var a = this.length;
        if (typeof b != "function") {
            throw new TypeError()
        }
        var d = arguments[1];
        for (var c = 0; c < a; c++) {
            if (c in this) {
                b.call(d, this[c], c, this)
            }
        }
    }
} (function() { ["forEach"].forEach(function(a) {
        if (!Array[a]) {
            Array[a] = function(b) {
                return Array.prototype[a].apply(b, Array.prototype.slice.call(arguments, 1))
            }
        }
    })
})();
TBM.Util = TBM.Util || {};
TBM.Util = function() {
    var c = [];
    function b(g) {
        return (g.nodeType == 1) ? g: document.getElementById(g)
    }
    function f() {
        Array.forEach(c,
        function(g) {
            if (typeof g == "function") {
                g()
            }
        })
    }
    function e(i, h) {
        h = h || window;
        var k = h.document,
        g = false;
        var j = function() {
            if (!g) {
                g = true;
                i()
            }
        }; (function() {
            try {
                k.documentElement.doScroll("left")
            } catch(l) {
                setTimeout(arguments.callee, 50);
                return
            }
            j()
        })()
    }
    var a = function() {
        return !! window.ActiveXObject
    } ();
    var d = function() {
        return a && !window.XMLHttpRequest
    } (); (function() {
        if (document.addEventListener) {
            document.addEventListener("DOMContentLoaded", f, false)
        } else {
            e(f)
        }
    })();
    return {
        isIE: a,
        isIE6: d,
        trim: function(g) {
            return g.replace(/^\s+|\s+$/g, "")
        },
        get: b,
        getElementsByClassName: function(n, h, j) {
            n = this.trim(n);
            h = h || "*";
            j = (j) ? b(j) : null || document;
            if (!j) {
                return []
            }
            var k = [],
            o = j.getElementsByTagName(h),
            m = this.hasClass;
            for (var l = 0,
            g = o.length; l < g; ++l) {
                if (m(o[l], n)) {
                    k[k.length] = o[l]
                }
            }
            return k
        },
        hasClass: function(h, g) {
            h = b(h);
            if (!h || !g || !h.className) {
                return false
            }
            return h.className.indexOf(g) > -1
        },
        addClass: function(h, g) {
            h = b(h);
            if (!h || !g) {
                return
            }
            if (this.hasClass(h, g)) {
                return
            }
            h.className += " " + g
        },
        removeClass: function(h, g) {
            h = b(h);
            if (!this.hasClass(h, g)) {
                return
            }
            h.className = h.className.replace(new RegExp(g, "g"), "");
            if (!this.trim(h.className)) {
                h.removeAttribute(this.isIE ? "className": "class")
            }
        },
        getEvt: function(g) {
            return window.event || g
        },
        getTarget: function(h) {
            h = this.getEvt(h);
            var g = h.srcElement || h.target;
            try {
                if (g && 3 == g.nodeType) {
                    return g.parentNode
                }
            } catch(i) {}
            return g
        },
        addEvent: function(i, h, g) {
            i = b(i);
            if (!i || !h || typeof(g) != "function") {
                return
            }
            if (i.addEventListener) {
                i.addEventListener(h, g, false)
            } else {
                if (i.attachEvent) {
                    i.attachEvent("on" + h, g)
                }
            }
        },
        stopPropagation: function(g) {
            g = this.getEvt(g);
            if (g.stopPropagation) {
                g.stopPropagation()
            } else {
                g.cancelBubble = true
            }
        },
        preventDefault: function(g) {
            g = this.getEvt(g);
            if (g.preventDefault) {
                g.preventDefault()
            } else {
                g.returnValue = false
            }
        },
        onDOMReady: function(g) {
            c.push(g)
        }
    }
} ();
TBM.Mall = TBM.Mall || {};
TBM.Mall = function() {
    var e = TBM.Util;
    var b = 100;
    var d = "current";
    var a = null;
    var c = false;
    return {
        showSubItems: function(h) {
            h = e.get(h);
            if (!h) {
                return false
            }
            var k;
            var g = e.getElementsByClassName("subcontent", "div", h);
            function i(l, n) {
                var m = e.getTarget(l);
                k = setTimeout(function() {
                    while (m.parentNode != h) {
                        m = m.parentNode
                    }
                    e.addClass(m, d)
                },
                b)
            }
            function f(l, n) {
                if (k) {
                    clearTimeout(k)
                }
                var m = e.getTarget(l);
                while (m.parentNode != h) {
                    m = m.parentNode
                }
                e.removeClass(m, d)
            }
            try {
                e.addEvent(h, "mouseover", i);
                e.addEvent(h, "mouseout", f);
                Array.forEach(g,
                function(l) {
                    e.addEvent(l, "mouseover",
                    function(m) {
                        e.addClass(l.parentNode, d)
                    });
                    e.addEvent(h, "mouseout",
                    function(m) {
                        e.removeClass(l.parentNode, d)
                    })
                })
            } catch(j) {}
        },
        toggleAllItems: function(f, k) {
            f = e.get(f);
            k = e.get(k);
            if (!f || !k) {
                return false
            }
            var i = f.parentNode;
            var j = k.parentNode;
            function g() {
                e.addClass(i, "collapse-head");
                e.addClass(f, "extend-trigger");
                e.addClass(k, "show")
            }
            function h() {
                e.removeClass(i, "collapse-head");
                e.removeClass(f, "extend-trigger");
                e.removeClass(k, "show")
            }
            j.onmouseover = g;
            j.onmouseout = h
        },
        simulateSelect: function(f, n) {
            f = e.get(f);
            n = e.get(n);
            try {
                var o = f.getElementsByTagName("span")[0];
                var m = f.getElementsByTagName("ul")[0];
                var j = m.parentNode;
                var l = m.getElementsByTagName("li");
                var i, g;
                j.isShow = false;
                if (l.length) {
                    //var h = e.getElementsByClassName("selected", "li", m);
                    i = l[0];
                    g = i.getAttribute("value");
                    o.innerHTML = i.innerHTML;
                    n.value = (g == "") ? "1": g
                } else {
                    return
                }
                e.addEvent(o, "click",
                function(p) {
                    e.stopPropagation(p);
                    if (a && a != j) {
                        e.removeClass(a, "extend");
                        a.isShow = false
                    }
                    if (!j.isShow) {
                        e.addClass(j, "extend");
                        j.isShow = true;
                        a = j
                    } else {
                        e.removeClass(j, "extend");
                        j.isShow = false
                    }
                });
                e.addEvent(document.body, "click",
                function(p) {
                    e.stopPropagation(p);
                    e.removeClass(j, "extend");
                    j.isShow = false
                });
                Array.forEach(l,
                function(p) {
                    if (e.isIE6) {
                        e.addEvent(p, "mouseenter",
                        function() {
                            e.addClass(p, d)
                        });
                        e.addEvent(p, "mouseleave",
                        function() {
                            e.removeClass(p, d)
                        })
                    }
                    e.addEvent(p, "click",
                    function(s) {
                        var q = e.getEvt(s);
                        var r = e.getTarget(q);
                        o.innerHTML = r.innerHTML;
                        n.value = r.getAttribute("value");
                        e.removeClass(j, "extend");
                        j.isShow = false
                    })
                })
            } catch(k) {}
        },
        init: function() {
            if (c) {
                return
            }
            c = true;
            var f = e.get("searchTop");
            this.toggleAllItems("J_Toggle", "J_Allitems_Content");
            this.showSubItems("J_Menu");
            this.simulateSelect("J_Select_type", "type");
            this.simulateSelect("J_Select_cat", "searchtype");
            e.addEvent(f, "submit",
            function(i) {
                e.preventDefault(i);
                var g = e.get("searchinput"),
                h = e.get("searchtype").value;
                if (!g.value && (h === "" || h === "all")) {
                    alert("\u5173\u952e\u5b57\u4e0d\u80fd\u4e3a\u7a7a!");
                    g.focus();
                    return
                }
                f.submit()
            })
        }
    }
} ();